package com.tjresearch.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.tjresearch.pojo.Item;

@Repository
public class RedisDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	
	public List<Item> queryItemsByThemeId() {
		String sql = "select item_id,item_name,datatype_id,item_unit,area_code,remark from coal_item where theme_id = 22";
		return jdbcTemplate.query(sql,new RowMapper<Item>(){
				@Override
				public Item mapRow(ResultSet rs, int rowNum) throws SQLException {
					Item item = new Item();
					item.setAreaCode(rs.getString("area_code"));
					item.setDatatypeId(rs.getInt("datatype_id"));
					item.setItemId(rs.getInt("item_id"));
					item.setItemName(rs.getString("item_name"));
					item.setItemUnit(rs.getString("item_unit"));
					item.setRemark(rs.getString("remark"));
					return item;
				}
			
		});
	}

	
	
	

}
